package com.wallace.downloadserver

import com.wallace.downloadserver.bean.MyInterface
import com.wallace.downloadserver.service.MyInterfaceService
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest

/**
 * @Description:
 * ListToVarcharHandlerTest
 * @author WallaceListToVarcharHandler
 * @Date 2022/1/28 15:26
 */
@SpringBootTest
internal class ListHandleTest {

    private val log: Logger = LoggerFactory.getLogger(javaClass)

    @Autowired
    private var myInterfaceService: MyInterfaceService? = null

    @BeforeEach
    fun initDB() {
        deleteAll()
    }

    @AfterEach
    fun initDB1() {
        deleteAll()
    }

    private fun deleteAll() {
        myInterfaceService?.deleteAll()
    }

    @Test
    fun insertTest() {
        insert()
    }

    fun insert() {
        log.debug("start to test insert and select method...")
        myInterfaceService?.insert(record = MyInterface(
                id = 1,
                methodName = "testMethod",
                path = arrayListOf("/path/test1", "/path/test2")
        ))
        assert(myInterfaceService?.selectByPrimaryKey(id = 1) != null)
    }
}